#ifndef __TCPSERVER_H_
#define __TCPSERVER_H_

#include "Acceptor.hpp"
#include "EventLoop.hpp"

namespace ln{

class TcpServer{
public:
    TcpServer(unsigned short port,const char * ip = "127.0.0.1")
    :_acceptor(port,ip)
    ,_loop(_acceptor)
    {
        _acceptor.ready();
    }

    void start(){
        _loop.loop();
    }

    void stop(){
        _loop.unloop();
    }

    void setAllCallbacks(Callback && cb1,Callback && cb2,Callback && cb3){
        _loop.setAllCallbacks(std::move(cb1),std::move(cb2),std::move(cb3));
    }

private:
    Acceptor  _acceptor;
    EventLoop _loop;
};

}//end of namespace ln

#endif

